package com.zima.mall.controller;

import com.zima.mall.service.CartService;
import com.zima.mall.vo.TableVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "/cart")
public class CartController {
    @Resource
    private CartService cartService;

    @RequestMapping(value = "/findAllByAccount/{account}")
    public TableVo findAllByAccount(@PathVariable String account){
        return cartService.findAllByAccount(account);
    }

    @RequestMapping("/delById/{id}")
    public Integer delById(@PathVariable Integer id){
        return cartService.delById(id);
    }

    @RequestMapping("/add/{account}/{productId}")
    public Integer add(@PathVariable String account,@PathVariable Integer productId){
        return cartService.add(account,productId);
    }

}
